package bloodfang.data;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;

import au.com.bytecode.opencsv.CSVReader;


public class RandomPropPoints {
	
	static CSVReader reader = null;
	
	public HashMap<Integer,String[]> random_prop_points = read("data/WoD_RandPropPoints.dbc.csv",0);
	
	private static String format(String input){
		return input.replace("\"", "").replace("{", "").replace("}", "").trim();
	}
	
	private static HashMap<Integer,String[]> read(String file,int field){
		HashMap<Integer,String[]> data = new HashMap<Integer,String[]>();
		try {
			reader = new CSVReader(new FileReader(file), ',', '\'', 1);
			String[] nextLine = null;
			while ((nextLine = reader.readNext()) != null) {
				if(nextLine.length == 1) continue;
				nextLine[field] = format(nextLine[field]);
		        data.put(Integer.parseInt(nextLine[field]),nextLine);
		    }
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return data;
	}
	
	public int get(int itemlevel,boolean blue){
		int offset = blue ? 6 : 1;
		return Integer.parseInt(random_prop_points.get(itemlevel)[offset]);
	}
}
